export default function useIntervalFn(cb, delay) {
  let timer = null;

  const start = () => {
    // 避免频繁开启
    timer && clearInterval(timer);
    timer = setInterval(() => {
      cb();
    }, delay);
  }

  const stop = () => {
    timer && clearInterval(timer);
  }

  return {
    start,
    stop
  }
}